package com.example.fresheveryday.service.Impl;

import com.example.fresheveryday.po.User;
import com.example.fresheveryday.mapper.UserMapper;
import com.example.fresheveryday.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ll
 * @since 2023-07-05
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    UserMapper userMapper;
    @Override
    public User queryUserByUserId(String userId) {
        return userMapper.queryUserByUserId(userId);
    }

    @Override
    public void checkLogin(String email, String password) throws Exception{
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken(email,password);
        subject.login(token);
    }
}
